<extend name="./Tpl/Plus/base.html" />
<block name="main">

<div class="col-xs-12">
    <p>
    <a href="{:U("Member/Plus/opt?code=$code")}" class="btn btn-primary">
    </i>投票函列表 </a>
    </p>
    <div class="widget-box">
        <div class="widget-header header-color-blue">
            <h5 class="bigger lighter">
            基本信息
            </h5>
        </div>
        <div class="widget-body">
            <div class="widget-main">
                  <div class="form-group">
                    <label for="keyword">查询关键字</label>
                    <input type="text" vid="{$vo.id}" value="{$vo.keyword}" name="keyword" class="form-control" id="keyword" >
                  </div>
                  <div class="form-title">
                    <label for="title">投票主题</label>
                    <input type="text" vid="{$vo.id}" value="{$vo.title}"  class="form-control"  name="title"  >
                  </div>
                  <!-- <div class="form-title">
                    <label for="title">单选 / 多选</label>
                    <select vid="{$vo.id}" data="{$vo.issingle}"  class="form-control input-large"  name="issingle" >
                      <option value="1">单选</option>
                      <option value="0">多选</option>
                    </select>
                  </div> -->
                  <div class="form-group">
                    <label for="intro">投票说明</label>
                    <textarea vid="{$vo.id}" class="form-control" placeholder="可以不填写" name="desc">{$vo.desc}</textarea>
                  </div>
                  <div class="form-group">
                    <label for="intro">投票结果</label>
                    <textarea vid="{$vo.id}" class="form-control" placeholder="可以不填写" name="intro">{$vo.intro}</textarea>
                  </div>
            </div>
        </div>
    </div>

    <div class="widget-box">
        <div class="widget-header header-color-blue">
            <h5 class="bigger lighter">
            选项
            </h5>
        </div>
        <div class="widget-body">
            <div class="widget-main">
            <volist name="itemlist" id="item">
              <div class="col-md-5">
                  <div class="form-group">
                      <label class="no-padding-right" for="form-field-1">投票选项</label>
                      <input ajaxitem name="title" itemid="{$item.id}" value="{$item.title}" type="text" class="form-control"  >
                  </div>
              </div>
              <div class="col-md-1">
                  <div class="form-group">
                      <label class="no-padding-right" for="form-field-1"></label>
                      <div class="clearfix"></div>
                      <a href="{:U("Member/Plus/deleteitem?code=$code&itemid=$item[id]")}" class="btn btn-danger deleteitem">
                      <i class="icon-remove"></i></a>
                  </div>
              </div>
            </volist>
                        <div class="clearfix"></div>
            <div class="field_form">
            <div class="col-md-5">
                <div class="form-group">
                    <label class="no-padding-right" for="form-field-1">投票选项</label>
                    <input name="title" type="text" class="form-control"  >
                    <input type="hidden" name="vid" value="{$vo.id}">
                </div>
            </div>
            <div class="col-md-1">
                <div class="form-group">
                    <label class="no-padding-right" for="form-field-1"></label>
                    <div class="clearfix"></div>
                    <a href="#" class="btn btn-info insertfield">
                    <i class="icon-ok"></i></a>
                </div>
            </div>
            </div>
                        <div class="clearfix"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(function(){
    $('input[vid],textarea[vid],select[vid]').on('change',function(){
        var url = "{:U("Member/Plus/updatevote?code=$code")}";
        var fname = $(this).attr('name');
        var fvalue = $(this).val();
        var id = "{$Think.get.id}";
        $.post(url,{fname:fname,fvalue:fvalue,id:id},function(req){
            //
        })
    })
    $('input[ajaxitem]').on('change',function(){
        var url = "{:U("Member/Plus/updateitem?code=$code")}";
        var id = $(this).attr('itemid');
        var title = $(this).val();
        $.post(url,{id:id,title:title},function(req){
            // location.reload();
        })
        return false;
    })
    $('a.deleteitem').on('click',function(){
        var url = $(this).attr('href');
        $.get(url,{},function(req){
            location.reload();
        })
        return false;
    })
    $('a.insertfield').on('click',function(){
        var url = "{:U("Member/Plus/insertitem?code=$code")}";
        var obj  = $(this).parent().parent().parent();
        var form = obj.find('input').serialize();
        $.post(url,form,function(req){
            obj.find('input').val('');
            location.reload();
        })
        return false;
    })
})    
</script>
</block>
